<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
</head>
<body>
<?php
/**
* 商品类
*/
class ShopProduct
{
    
}
$p1 = new ShopProduct();
var_dump($p1);
/**
* 商品类2
*/
class ShopProduct2
{
    public $price = 0;
    public $shopName = '';
    public $factory = '';
    private $discount = 1;
    public function setName($str = '')
    {
        return $this->shopName = $str;
    }
    private function setDiscount($value=1)
    {
        $this->discount = $value;
    }
}
$p2 = new ShopProduct2();
$p2->shopName = '建站服务';
// $p2->discount = 0.5;
$p2->setName('网站维护服务');
var_dump($p2->shopName);
/**
* 拥有构造方法的类
*/
class ShopProduct3 extends ShopProduct2
{
    
    function __construct($price, $shopName, $factory, $discount)
    {
        $this->price = $price;
        $this->shopName = $shopName;
        $this->factory = $factory;
        $this->discount = $discount;
    }
}
$p3 = new ShopProduct3(99.9,'服务','aliyun',1);
$p3->setName('网站维护服务');
$p3->setDiscount(0.9);
var_dump($p3->shopName,$p3->discount);
?>
</body>
</html>